package com.yuma.reffunc;

import java.util.function.Supplier;

class Person{
    String name;
    int age;
    public Person() {
        name = "yuma";
        age = 2;
    }
    public Person(String name, int age){
        this.name = name;
        this.age = age;
    }
    @Override
    public String toString() {
        return "Person{" + "name='" + name + '\'' + ", age=" + age + '}';
    }
}
interface ConstructorRef<T,U1,U2>{
    T create(U1 u1, U2 u2);
}
public class ConstructorFunctionRefDemo {
    public static void main(String[] args) {
        // Supplier<String>
        Supplier<String> s1 = String::new;
        System.out.println(s1.get());  // new String();
        Supplier<Person> s2 = Person::new;
        System.out.println(s2.get());  // new Person();
        ConstructorRef<Person, String, Integer> c1 = Person::new;
        System.out.println(c1.create("李四",30));   // new Person("李四",30);
    }
}
